package com.ae28113.adult_education.common;

import lombok.Data;

//通用响应结果
@Data
public class R<T> {
    private int code;
    private String msg;
    private T data;

    public R() {    }

    public R(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(int code, String msg,T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> R<T> ok(){
        return new R<T>(0,"success");
    }

    public static <T> R<T> ok(T data){
        return new R<T>(0,"success",data);
    }

    public static <T> R<T> fail(){
        return new R<T>(0,"fail");
    }

    public static <T> R<T> fail(String msg){
        return new R<T>(-1,msg);
    }
}
